package sword.T4;

/**
 * @File Info: leetcode -- <Solution>
 * @Author: 18362
 * @Create: 2022-03-04 14:14:19 星期五
 */

class Solution {
    public boolean findNumberIn2DArray(int[][] matrix, int target) {
        int m = matrix.length;
        if (m == 0)
            return false;
        int n = matrix[0].length;
        if (n == 0)
            return false;
        int row = 0, col = n-1;
        while (row < m && col >= 0) {
            if (target == matrix[row][col])
                return true;
            else if (target > matrix[row][col]) {
                row++;
            } else {
                col --;
            }
        }
        return false;
    }
}
